<!--_meta 作为公共模版分离出去-->
<#include "include/_meta.html">
<!--/meta 作为公共模版分离出去-->
<script src="vue/vue.min.js"></script>
<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="lib/layer/2.1/layer.js"></script>
<title>车辆管理-添加保险记录</title>
<meta name="keywords" content="汽车租赁">
<meta name="description" content="H-ui.admin v2.3，是一款由国人开发的轻量级扁平化网站后台模板，完全免费开源的网站后台管理系统模版，适合中小型CMS后台系统。">
</head>
<body>
<article class="page-container">
	<form class="form form-horizontal" id="form-insurance-add" >
	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>车牌号：</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="text" class="input-text" autocomplete="off" value="" placeholder="车牌号" id="carIdCard" name="carIdCard">
		</div>
	</div>		
	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>保险公司：</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="text" class="input-text" autocomplete="off" value="" placeholder="保险公司" id="company" name="company">
		</div>
	</div>	
	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>出险电话：</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="text" class="input-text" autocomplete="off" value="" placeholder="出险电话" id="companyPhone" name="companyPhone">
		</div>
	</div>	
	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>保险编号：</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="text" class="input-text" autocomplete="off" value="" placeholder="保险编号" id="code" name="code">
		</div>
	</div>		
	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>保险内容：</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="text" class="input-text" autocomplete="off" value="" placeholder="保险内容" id="codeContent" name="codeContent">
		</div>
	</div>		
	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>保险费用：</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="text" class="input-text" autocomplete="off" value="" placeholder="保险费用" id="money" name="money">
		</div>
	</div>					
	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>生效日期：</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="text"  class="input-text Wdate" onfocus="WdatePicker({skin:'whyGreen',startDate:'%y-%M-%d %H:00:00',dateFmt:'yyyy-MM-dd HH:mm:ss'})" autocomplete="off"  placeholder="生效日期" id="carInsuranceStart" name="carInsuranceStart">
		</div>																	
	</div>
	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>失效日期：</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="text"  class="input-text Wdate" onfocus="WdatePicker({skin:'whyGreen',startDate:'%y-%M-%d %H:00:00',dateFmt:'yyyy-MM-dd HH:mm:ss'})" autocomplete="off"  placeholder="失效日期" id="carInsuranceEnd" name="carInsuranceEnd">
		</div>
	</div>

	<div class="row cl" >
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>经办人：</label>
		<div class="formControls col-xs-8 col-sm-9">
			<select type="text" class="input-text" id="userName" name="userName" >

					<optgroup label="--请选择经办人--">
						<option v-for="(item,index) in result">{{item.userName}}</option>

			</select>
		</div>
	</div>

	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3">备注：</label>
		<div class="formControls col-xs-8 col-sm-9">
			<textarea id="remark" name="remark" cols="" rows="" class="textarea"  placeholder="说点什么...100个字符以内" dragonfly="true"></textarea>
			<p class="textarea-numberbar"><em class="textarea-length">0</em>/100</p>
		</div>
	</div>

	<div class="row cl">
		<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
			<input onclick="submitaaa()" class="btn btn-primary radius" type="button" value="提交"/>
		</div>
	</div>
	</form>
</article>
<script type="text/javascript">
	var app = new Vue({
		el: '#form-insurance-add',
		data: {
			result: []
		}
	});

	var getUserById = function () {
		$.ajax({
			type:"post",
			dataType:"json",
			url:"/getAllUser",
			success:function(msg){
				app.result = msg;
			}
		})
	}

	getUserById();

	var closec = function () {
		var thisName = parent.layer.getFrameIndex(window.name);
		parent.layer.close(thisName);
	}
	
	var submitaaa = function () {
		let mustData = ['carIdCard', 'company', 'companyPhone', 'code', 'codeContent', 'money', 'carInsuranceStart', 'carInsuranceEnd', 'userName'];
		let mustDataTip = ['车牌号不能为空', '保险公司不能为空', '出险电话不能为空', '保险编号不能为空', '保险内容不能为空', '保险费用不能为空', '生效日期不能为空', '失效日期不能为空', '经办人不能为空'];
		let canSet = true;
		console.log(this.form);
		for (let i = 0; i < mustData.length; i++) {
			if ($("#" + mustData[i]).val() == '') {
				layer.msg("必填:" + mustDataTip[i], {icon: 5});
				canSet = false;
				break;
			}
		};
		if (canSet) {
			$.ajax({
				type: "POST",
				url: "/addInsurance",
				data: $("#form-insurance-add").serialize(),
				dataType: "json",
				success: function (result) {
					if (result.flag == 1) {
						layer.msg(result.flag + ":" + result.msg, {icon: 6});
					} else {
						layer.msg(result.flag + ":" + result.msg, {icon: 5});
					}
					closec();
				}
			});
		}
	}
</script>
</body>
</html>